#!/bin/bash
#
# buildall.sh - copyright 2009 - Garrett Honeycutt - code@garretthoneycutt.com
#
# License: GPLv2
#
# Purpose:
#   Build iptables scripts for all hosts. This will only cause changes in hosts
#   that have changed.
#
# Usage: ./buildiptables <hostname>
#
# Returns: 0 on success, non-zero on failure
#

# directory containing host files
HOSTDIR="hosts"

# check that HOSTDIR exists
if [ ! -d $HOSTDIR ]; then
    echo "Directory $HOSTDIR does not exist"
    exit 1
fi

# iterate over all hosts in $HOSTDIR
for host in $(ls ${HOSTDIR}/)
do
    ./buildiptables $host
done
